
<!DOCTYPE html>
<ui:composition template="/master.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">

	<ui:define name="content">
		<h:form id="formPais">

			<p:growl id="msgs" showDetail="true" life="1000" />
			<p:panel header="Países" style="border: none;">

				<p:dataTable id="singleDT" var="pa" value="#{paisBean.paises}"
					selection="#{paisBean.selectedPais}" rowKey="#{pa.nombrePais}"
					editable="true" style="width:50%" rows="5" paginator="true"
					paginatorPosition="bottom"
					paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}">

					<p:ajax event="rowEdit" listener="#{paisBean.onRowEdit}"
						update=":#{p:component('msgs')}" />
					<p:ajax event="rowEditCancel" listener="#{paisBean.onRowCancel}"
						update=":#{p:component('msgs')}" />

					<f:facet name="header">
						<p:outputPanel style="text-align:right">
							<h:outputText value="Buscar: " />
							<p:inputText id="globalFilter" onkeyup="PF('paisTable').filter()"
								style="width:150px" placeholder="Ingrese País" />
						</p:outputPanel>
					</f:facet>

					<p:column headerText="País" style="text-align:left">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{pa.nombrePais}" />
							</f:facet>
							<f:facet name="input">
								<p:inputText id="modelInput" value="#{pa.nombrePais}"
									style="width:100%" />
							</f:facet>
						</p:cellEditor>
					</p:column>
					<p:column headerText="Modificar"
						style="width:70px;text-align: center">
						<p:rowEditor />
					</p:column>

					<p:column headerText="Eliminar"
						style="width:32px;text-align: center">
						<p:commandButton process="singleDT"
							update=":#{p:component('singleDT')}" icon="ui-icon-close"
							title="View" action="#{paisBean.eliminarPais}">
							<f:setPropertyActionListener value="#{pa}"
								target="#{paisBean.selectedPais}" />

							<p:confirm header="Confirmación" message="Está seguro?"
								icon="ui-icon-alert" />
						</p:commandButton>
					</p:column>

				</p:dataTable>

				<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
					<p:commandButton value="Si" type="button"
						styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
					<p:commandButton value="No" type="button"
						styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
				</p:confirmDialog>

				<br />

				<p:fieldset id="panelNuevoPais" legend="Nuevo" toggleable="true"
					toggleSpeed="500" collapsed="true" style="width:46%">
					<p:messages id="messages" autoUpdate="false" />
					<h:panelGrid columns="3" cellpadding="5">
						<h:outputLabel for="nomPais" value="Nombre:" />
						<p:inputText id="nomPais" required="true" label="Nombre país"
							value="#{paisBean.pais.nombrePais}" />
						<p:message for="nomPais" display="icon" />
					</h:panelGrid>
					<p:separator id="separator" />
					<p:commandButton value="Guardar" id="ajax" process="@form"
						icon="ui-icon-disk" update=":#{p:component('formPais')}"
						actionListener="#{paisBean.guardarPais}" />
				</p:fieldset>
			</p:panel>

		</h:form>

</ui:define>
</ui:composition>